package com.zsc.springcloud;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/refresh")
// 会重新注入配置项
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public class RefreshController {

    @Value("${name}")
    private String name;

    @Value("${food}")
    private String food;

    @Value("${words}")
    private String words;

    @GetMapping("/words")
    private String getWords(){
        return words;
    }

    @GetMapping("/food")
    private String food(){
        return food;
    }
}
